<meta title="秒杀推广">
<div class="p">
    <div class="panel panel-success">
        <div class="panel-heading">
            <h4>秒杀宝贝管理</h4>
        </div>
        <div class="panel-body">
            <div class="p-b">
                <form class="form-inline m-b-wrapper-xs" id="form" s="form"
                      s-form="{action:function(){$page.node.val(1); $itemsGrid.refresh()}}"
                >
                    <select class="form-control" s="select"
                            s-build="S.get('/api/enum/valuesMap/core.enums.SeckillItemStatus?igNames=DELETED')"
                            name="status">
                        <option value="">选择状态</option>
                    </select>
                    <select class="form-control" s="select"
                            s-build="S.get('/api/enum/valuesMap/core.enums.EcomPlatform')"
                            name="ecomPlatform">
                        <option value="">电商平台</option>
                    </select>
                    <input autocomplete="off" type="hidden" name="page" id="page" value="1"/>
                    <input autocomplete="off" type="submit" class="btn btn-primary" value="查找"/>
                </form>
            </div>
            <table
                    id="itemsGrid"
                    s='datac,nda'
                    s-data="Smart.cleanJsonRef(S.get('/api/seckillItem/search', $form.node.serialize()))"
                    class="table table-stripped table-bordered">
                <tr>
                    <th>宝贝图片</th>
                    <th style="width: 250px;">宝贝标题</th>
                    <th>搜索关键字</th>
                    <th class="text-center">发货地</th>
                    <th class="text-center">原售价</th>
                    <th class="text-center">返现金额</th>
                    <th class="text-center">卖家</th>
                    <th class="text-center">数量</th>
                    <th class="text-center">剩余数量</th>
                    <th>推广时间</th>
                    <th class="text-center">担保金</th>
                    <th class="text-center">服务费</th>
                    <th class="text-center">总费用</th>
                    <th class="text-center">状态</th>
                    <th class="text-right">操作</th>
                </tr>
                <tbody s="loop" s-data-filter="'results'">
                <tr s-loop-role="empty">
                    <td colspan="15" class="alert alert-warning">
                        暂无宝贝，请先进行添加
                    </td>
                </tr>
                <tr s-loop-role="row" s="row,datac">
                    <td s="tpl">
                        <img src="{%=this.picUrl%}" style="max-width: 50px; max-height: 50px;"/>
                    </td>
                    <td s="tpl">
                        <a target="_blank" href="{%=this.itemUrl%}" external><span class="text-warning">【{%=this.ecomPlatformTitle%}】</span>{%=this.title%}</a>
                    </td>
                    <td name="keyword"></td>
                    <td class="text-center" name="location"></td>
                    <td class="text-center" name="salePrice"></td>
                    <td class="text-center" name="fanliAmount"></td>
                    <td class="text-center" name="sellerName"></td>
                    <td class="text-center" name="totalCount"></td>
                    <td class="text-center" name="remainCount"></td>
                    <td>
                        <span name="startTime"></span> -
                        <div name="endTime"></div>
                    </td>
                    <td class="text-center" name="deposit"></td>
                    <td class="text-center" name="serviceFee"></td>
                    <td class="text-center" name="totalFee"></td>
                    <td class="text-center" s="tpl">
                        <label class="label
                            {%
                                switch(this.status) {
                                    case 'WAIT_VERIFY': out.print('label-warning'); break;
                                    case 'ONSALE': out.print('label-success'); break;
                                    case 'WAIT_PAY': out.print('label-info');break;
                                    default: out.print('label-default');break;
                                }
                            %}
                        ">{%=this.statusTitle%}</label>
                    </td>
                    <td s="tpl" class="text-right">
                        {%if(this.status == 'WAIT_PAY' || this.status=='WAIT_VERIFY') {%}
                        <input autocomplete="off" type="button" s-click="onsale(this)" class="btn btn-xs btn-link" value="上架"/>
                        {%} else {%}
                        <input autocomplete="off" type="button" s-click="edit(this)" class="btn btn-xs btn-link" value="编辑"/>
                        {%}%}
                        {%if(this.status == 'ONSALE') {%}
                        <input autocomplete="off" type="button" s-click="instock(this)" class="btn btn-xs btn-link" value="下架"/>
                        {%}%}
                    </td>
                </tr>
                </tbody>
                <tfoot>
                <tr>
                    <td colspan="15" class="text-right">
                        <ul s="pagination" id="sellerPagination"
                            s-pagination="{action:function(){$page.node.val(this); $itemsGrid.refresh()}}"
                            class="pagination pagination-sm">
                        </ul>
                        共有<span name="total"></span>个宝贝
                    </td>
                </tr>
                </tfoot>
            </table>
        </div>
    </div>
</div>
<script type="text/javascript">
    function onsale($s) {
        var data = $s.parent().data();
        S.popupOpen("/seckill/onsale.html", {item: data}).done(function(rs) {
            rs && $itemsGrid.refresh()
        })
    }
    function edit($s) {
        var data = $s.parent().data();
        S.popupOpen("/seckill/edit.html", {item: data}).done(function(rs) {
            rs && $itemsGrid.refresh()
        })
    }

    function instock($s) {
        var data = $s.parent().data();
        S.popupOpen("/seckill/instock.html", {item: data}).done(function(rs) {
            rs && $itemsGrid.refresh()
        })
    }

</script>